import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _HomePageState();
  }
}

class _HomePageState extends State<HomePage> {
  int _selectedIndex = 0;

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text('demo'),
      // ),
      body: HomeBody(),
    );
  }
}

class HomeBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      // crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          child: Image.network(
            'https://images.unsplash.com/photo-1471115853179-bb1d604434e0?q=80&w=2864&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
            fit: BoxFit.contain,
          ),
        ),
        Container(
          height: 430,
          margin: EdgeInsets.fromLTRB(8, 16, 8, 16),
          child: GridView.count(
            crossAxisCount: 2,
            padding: EdgeInsets.zero,
            children: [
              GestureDetector(
                child: Container(
                    margin: EdgeInsets.all(8),
                    decoration: BoxDecoration(
                        border: Border.all(width: 1, color: Colors.black12),
                        borderRadius: BorderRadius.all(Radius.circular(8))),
                    child: Center(
                        child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Icon(Icons.image_rounded,
                            color: Colors.amber, size: 60),
                        Text('图片')
                      ],
                    ))),
                onTap: () {
                  print('object');
                  Navigator.pushNamed(context, '/images');
                },
              ),
              Container(
                  margin: EdgeInsets.all(8),
                  decoration: BoxDecoration(
                      border: Border.all(width: 1, color: Colors.black12),
                      borderRadius: BorderRadius.all(Radius.circular(8))),
                  child: Center(
                      child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(Icons.camera_alt, color: Colors.amber, size: 60),
                      Text('拍照')
                    ],
                  ))),
              GestureDetector(
                child: Container(
                  margin: EdgeInsets.all(8),
                  decoration: BoxDecoration(
                      border: Border.all(width: 1, color: Colors.black12),
                      borderRadius: BorderRadius.all(Radius.circular(8))),
                  child: Center(
                      child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Icon(Icons.text_fields, color: Colors.amber, size: 60),
                      Text('创作')
                    ],
                  )),
                ),
                onTap: () {
                  print('object');
                  Navigator.pushNamed(context, '/draw');
                },
              ),
              GestureDetector(
                child: Container(
                    margin: EdgeInsets.all(8),
                    decoration: BoxDecoration(
                        border: Border.all(width: 1, color: Colors.black12),
                        borderRadius: BorderRadius.all(Radius.circular(8))),
                    child: Center(
                        child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Icon(Icons.file_copy, color: Colors.amber, size: 60),
                        Text('素材')
                      ],
                    ))),
                onTap: () {
                  print('object');
                },
              )
            ],
          ),
        ),
      ],
    );
  }
}
